package com.ibm.mall.dao.impl;

import java.util.HashMap;
import java.util.Map;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.ibm.mall.base.DaoSupportImpl;
import com.ibm.mall.dao.UserDao;
import com.ibm.mall.model.User;

@Repository
public class UserDaoImpl extends DaoSupportImpl<User> implements UserDao {

	@Override
	public User getUserByUserAccount(String userAccount) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("userAccount", userAccount);
		String hql="from User u where u.userAccount=:userAccount";
		Query query=getSession().createQuery(hql);
		if (params != null && !params.isEmpty()) {
            for (String key : params.keySet()) {
            	query.setParameter(key, params.get(key));
            }
        }
		return (User) query.uniqueResult();
	}

}
